<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-back-button [text]="'core.back' | translate" />
        </ion-buttons>
        <ion-title>
            <h1>
                <core-format-text [text]="title" contextLevel="module" [contextInstanceId]="cmId" [courseId]="courseId" />
            </h1>
        </ion-title>
        <ion-buttons slot="end">
            @if (loaded) {
                <ion-button (click)="showToc()" [ariaLabel]="'addon.mod_book.toc' | translate" aria-haspopup="true">
                    <ion-icon name="fas-list-ul" slot="icon-only" aria-hidden="true" />
                </ion-button>
            }
        </ion-buttons>
    </ion-toolbar>
</ion-header>
<ion-content>
    <ion-refresher slot="fixed" [disabled]="!loaded" (ionRefresh)="doRefresh($event.target)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}" />
    </ion-refresher>

    <core-loading [hideUntil]="loaded">
        <div class="core-swipe-slides-container">
            <core-swipe-slides [manager]="manager" [options]="swiperOpts">
                <ng-template let-chapter="item" let-active="active">
                    <div class="ion-padding" core-reading-mode>
                        <core-format-text [component]="component" [componentId]="cmId" [text]="chapter.content" contextLevel="module"
                            [contextInstanceId]="cmId" [courseId]="courseId" [disabled]="!active" />
                        @if (chapter.tags?.length > 0) {
                            <div class="ion-margin-top">
                                <strong>{{ 'core.tag.tags' | translate }}: </strong>
                                <core-tag-list [tags]="chapter.tags" />
                            </div>
                        }
                    </div>
                </ng-template>
            </core-swipe-slides>
        </div>
    </core-loading>

    @if (loaded && displayNavBar && navigationItems.length > 1) {
        <core-navigation-bar collapsible-footer appearOnBottom [items]="navigationItems" previousTranslate="addon.mod_book.navprevtitle"
            nextTranslate="addon.mod_book.navnexttitle" (action)="changeChapter($event.id)" slot="fixed" />
    }
</ion-content>
